using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using DTO;
using System.Configuration;
using System.Data;
namespace DAL
{
    public class tbBangXepHangDAL
    {
        public static tbBangXepHangDAL CreatetbBangXepHangDAL()
        { 
            return new tbBangXepHangDAL(); 
        }

        private SqlConnection cn = null;
    
        public tbBangXepHangDAL()
        {
                cn = new SqlConnection(ConfigurationManager.ConnectionStrings["strConnection"].ConnectionString);
                cn.Open();
        }

        public tbBangXepHangDAL(tbBangXepHangDAL bxh )
        {
                this.cn = new SqlConnection(ConfigurationManager.ConnectionStrings["strConnection"].ConnectionString);
           
         this.cn.Open();
        }
        public void Insert(tbBangXepHangDTO bxh)
        {
            SqlCommand cmd = new SqlCommand("tbBangXepHang_Insert", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@sott", bxh.SoTT);
            cmd.Parameters.AddWithValue("@tendoibong", bxh.TenDoiBong);
            cmd.Parameters.AddWithValue("@trandau", bxh.TranDau);
            cmd.Parameters.AddWithValue("@tranthang", bxh.TranThang);
            cmd.Parameters.AddWithValue("@tranhoa", bxh.TranHoa);
            cmd.Parameters.AddWithValue("@tranthua", bxh.TranThua);
            cmd.Parameters.AddWithValue("@banthang", bxh.BanThang);
            cmd.Parameters.AddWithValue("@banthua", bxh.BanThua);
            cmd.Parameters.AddWithValue("@hieuso", bxh.HieuSo);
            cmd.Parameters.AddWithValue("@diemso", bxh.DiemSo);
            cmd.ExecuteNonQuery();
        }
        public void Update(tbBangXepHangDTO bxh)
        {
            SqlCommand cmd = new SqlCommand("tbBangXepHang_Update", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@mabxh", bxh.MaBXH);
            cmd.Parameters.AddWithValue("@sott", bxh.SoTT);
            cmd.Parameters.AddWithValue("@tendoibong", bxh.TenDoiBong);
            cmd.Parameters.AddWithValue("@trandau", bxh.TranDau);
            cmd.Parameters.AddWithValue("@tranthang", bxh.TranThang);
            cmd.Parameters.AddWithValue("@tranhoa", bxh.TranHoa);
            cmd.Parameters.AddWithValue("@tranthua", bxh.TranThua);
            cmd.Parameters.AddWithValue("@banthang", bxh.BanThang);
            cmd.Parameters.AddWithValue("@banthua", bxh.BanThua);
            cmd.Parameters.AddWithValue("@hieuso", bxh.HieuSo);
            cmd.Parameters.AddWithValue("@diemso", bxh.DiemSo);
            cmd.ExecuteNonQuery();
        }
        public void Detele(int iD)
        {
            SqlCommand cmd = new SqlCommand("tbBangXepHang_Detele", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@mabxh", iD);
            cmd.ExecuteNonQuery();
        }
   }
}
